package org.example.spring;

import org.example.spring.utils.TransactionUtil;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;


@SpringBootApplication
@EnableTransactionManagement
@MapperScan(basePackages = {"org.example.spring.repository.mapper"})
public class App implements CommandLineRunner {

    @Autowired
    private PlatformTransactionManager platformTransactionManager;



    public static void main( String[] args ) {
        SpringApplication.run(App.class,args);
    }

    @Override
    public void run(String... args) throws Exception {
        TransactionUtil.setTransactionManager(platformTransactionManager);
    }
}
